/**
 *
 */
package demo.tellurium.module.widget


import groovy.lang.MetaClass;

import demo.tellurium.framework.BaseUIModule;

/**
 * @author roger.xu
 *
 */
class CheckBoxDemo extends BaseUIModule {

    private static final String MODULE_NAME = "CheckBoxDemo";

    @Override
    public String getModuleName() {
        return MODULE_NAME;
    }

    @Override
    public void defineUi() {
        ui.Container(uid: "CheckBoxDemo") {
            DOJO_CheckBox(uid: "CheckBox1", clocator: [tag: "div", widgetid: "checkbox_demo"])
            List(uid: "List", clocator: [tag: "ul", id: "list"], separator: "li:visible") {
                Container(uid: "{all}", respond: ["click"]) {
                    DOJO_CheckBox(uid: "CheckBox")
                    UrlLink(uid: "Link", clocator: [tag: "a"])
                }
            }
        }
    }

    public void doClickCheckBox() {
        def checkboxUid = "CheckBoxDemo.CheckBox1";

        console.debug(getLocator(checkboxUid));
        onWidget(checkboxUid, "clickCheckBox");
    }

    public void doClickCheckBoxInList(int index) {
        def listUid = "CheckBoxDemo.List";
        def optionUid = String.format("%s[%d]", listUid, index);

        click optionUid
        pause 1000

        def checkboxUid = String.format("%s.%s", optionUid, "CheckBox");
        console.debug(getLocator(checkboxUid));
        onWidget(checkboxUid, "clickCheckBox");
    }

}
